package com.topone.controller;

import com.topone.Enum.DynamicInfoEnum;
import com.topone.Exception.FanZoneException;
import com.topone.Utils.ResultVOUntil;
import com.topone.VO.ResultVO;
import com.topone.dataObject.DynamicInfo;
import com.topone.service.DynamicInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/1/21,0021.
 */

@RestController
@CrossOrigin
@RequestMapping("/buyer/dynamic")
@Slf4j
public class dynamicController {

    @Autowired
    private DynamicInfoService service;
    @GetMapping("/list")
    public ResultVO<Map<String,Object>> list(Map<String,Object> map){

        try {
           List<DynamicInfo> dynamicInfoList= service.dynamicInfoList(DynamicInfoEnum.success.getCode());
           map.put("dynamicInfoList",dynamicInfoList);
        }catch (FanZoneException e){
            log.error("【查询交流分享信息】失败 e={}",e.getMessage());
            map.put("error",e.getMessage());
            return ResultVOUntil.error(1,e.getMessage());
        }
        map.put("suceess","查询成功");
        log.info("【查询交流分享】成功");
        return ResultVOUntil.success(map);
    }

}
